

import * as THREE from 'three';
import Element, { GLTF, IObject3DMap } from '../State/Element';

export default function getObject3D(element?: Element<keyof IObject3DMap>): THREE.Object3D | undefined {
    if (!element) return;
    if (element.type === 'gltf') {
        return (element.object3D as GLTF).scene.scene;
    } else if (element.type === 'light') {
        return element.object3D as THREE.Light;
    } else if (element.type === 'tag') {
        return element.object3D as THREE.Mesh;
    } else if (element.type === 'object3D') {
        return element.object3D as THREE.Object3D;
    }
}